<?php
namespace model\admin;
use model;
class paymentModel extends model{

    public static function get_list(){

        $sql = "select * from sh_payment ";
        $result = self::$db->query( $sql );
        return $result->rows;
    }

    public static function info( $payment_id ){

        $sql = "select * from sh_payment where id=" . $payment_id;
        $result = self::$db->query( $sql );

        return $result->row;
    }

    public static function edit( $payment_id, $data ){

//        $data = [];

        $sql = "UPDATE 
                  sh_payment 
                SET
                  `name` = '" . $data['name'] . "',
                  `code` = '" . $data['code'] . "',
                  active = '" . $data['active'] . "' 
                  where id=" . $payment_id;

        $result = self::$db->query( $sql );

        return $result->num_rows;

    }

    public static function config_get( $code ){

        $sql = "select * from sh_payment_config where code='" . $code . "'";

        $result = self::$db->query( $sql );

        return $result->row;
    }

    public static function config_set( $code, $config ){

        $sql = "insert into sh_payment_config set code='".$code."',config='" . $config . "'";

        $result = self::$db->query( $sql );

        return $result->num_rows;

    }

    public static function config_remove( $code ){

        $sql = "delete from sh_payment_config where code='" . $code . "'";

        $result = self::$db->query( $sql );

        return $result->num_rows;
    }

}